<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="imlgw,半岛铁盒,blog,Java博客,程序员,个人博客,java開發,程序員,個人博客,Java">
    <meta name="description" content="大悲无泪，大悟无言，大笑无声。">
    <meta name="author" content="Resolmi">
    
    <title>
        
            CAS单点登陆系统Demo |
        
        Tadow
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="https://static.imlgw.top/blog/20210731/BtJz541CcmJU.ico">
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/css/font-awesome.min.css">
    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"imlgw.top","root":"/","language":"zh-CN","path":"search.json"};
    KEEP.theme_config = {"toc":{"enable":true,"number":true,"expand_all":true,"init_open":true},"style":{"primary_color":"#0066CC","avatar":"https://static.imlgw.top/blog/20210731/3C7hCSRR3lfq.png","favicon":"https://static.imlgw.top/blog/20210731/BtJz541CcmJU.ico","article_img_align":"left","left_side_width":"260px","content_max_width":"920px","hover":{"shadow":false,"scale":true},"first_screen":{"enable":true,"background_img":"/images/image.svg","description":"Keep It Simple & Stupid."},"scroll":{"progress_bar":{"enable":true},"percent":{"enable":true}}},"local_search":{"enable":true,"preload":false},"code_copy":{"enable":true,"style":"default"},"pjax":{"enable":true},"lazyload":{"enable":true},"version":"3.4.3"};
    KEEP.language_ago = {"second":"%s 秒前","minute":"%s 分钟前","hour":"%s 小时前","day":"%s 天前","week":"%s 周前","month":"%s 月前","year":"%s 年前"};
  </script>
<meta name="generator" content="Hexo 5.4.0"><link rel="stylesheet" href="/css/prism.css" type="text/css"></head>


<body>
<div class="progress-bar-container">
    
        <span class="scroll-progress-bar"></span>
    

    
        <span class="pjax-progress-bar"></span>
        <span class="pjax-progress-icon">
            <i class="fas fa-circle-notch fa-spin"></i>
        </span>
    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                Tadow
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                首页
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                归档
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/categories"
                            >
                                分类
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/sbe"
                            >
                                订阅
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/links"
                            >
                                友链
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/about"
                            >
                                关于
                            </a>
                        </li>
                    
                    
                        <li class="menu-item search search-popup-trigger">
                            <i class="fas fa-search"></i>
                        </li>
                    
                </ul>
            </div>
            <div class="mobile">
                
                    <div class="icon-item search search-popup-trigger"><i class="fas fa-search"></i></div>
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">首页</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">归档</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/categories">分类</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/sbe">订阅</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/links">友链</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/about">关于</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="article-content-container">

        <div class="article-title">
            <span class="title-hover-animation">CAS单点登陆系统Demo</span>
        </div>

        
            <div class="article-header">
                <div class="avatar">
                    <img src="https://static.imlgw.top/blog/20210731/3C7hCSRR3lfq.png">
                </div>
                <div class="info">
                    <div class="author">
                        <span class="name">Resolmi</span>
                        
                            <span class="author-label">BOSS</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fas fa-edit"></i>&nbsp;2018-11-17 00:00:00
    </span>
    
        <span class="article-categories article-meta-item">
            <i class="fas fa-folder"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/categories/Web/">Web</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fas fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/tags/CAS/">CAS</a>&nbsp;
                    </li>
                
                    <li>
                        | <a href="/tags/SSO/">SSO</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
        <span class="article-wordcount article-meta-item">
            <i class="fas fa-file-word"></i>&nbsp;<span>4.9k 字</span>
        </span>
    
    
        <span class="article-min2read article-meta-item">
            <i class="fas fa-clock"></i>&nbsp;<span>25 分钟</span>
        </span>
    
    
        <span class="article-pv article-meta-item">
            <i class="fas fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                    </div>
                </div>
            </div>
        

        <div class="article-content markdown-body">
            <h2 id="单点登陆系统-–CAS"><a href="#单点登陆系统-–CAS" class="headerlink" title="单点登陆系统 –CAS"></a>单点登陆系统 –CAS</h2><ul>
<li>关于CAS的介绍网上都有。这里主要记录如何使用，如何配置和集成一些框架。</li>
<li>CAS架构图<br><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="https://imlgwpicture.oss-cn-qingdao.aliyuncs.com/blogImage/CAS.PNG"
                      alt="OSS"
                ><br>CAS 的 SSO 实现方式可简化理解为： 1 个 Cookie 和 N 个 Session 。 CAS Server 创建 cookie，在所有应用认证时使用，各应用通过创建各自的 Session 来标识用户是否已登录。<br>用 户在一个应用验证通过后，以后用户在同一浏览器里访问此应用时，客户端应用中的过滤器会在 session 里读取到用户信息，所以就不会去 CAS Server 认证。如果在此浏览器里访问别的 web 应用时，客户端应用中的过滤器在 session 里读取不到用户信息，就会去 CAS Server 的 login 接口认证，但这时CAS Server 会读取到浏览器传来的 cookie （ TGC ），所以 CAS Server 不会要求用户去登录页面登录，只是会根据 service 参数生成一个 Ticket ，然后再和 web 应用做一个验 证 ticket 的交互而已。</li>
</ul>
<h3 id="1-配置CAS服务端"><a href="#1-配置CAS服务端" class="headerlink" title="1. 配置CAS服务端"></a>1. 配置CAS服务端</h3><p>从上面的架构图也可以大概知道CAS运作的方式,首先配置好CAS的Server端，直接将CAS的war包拷到tomcat的webapp目录下然后启动tomcat自动解压就可以了，这里我设置的tomcat的端口是8888，地址栏输入localhost:8888/cas能看到CAS的登陆界面说明部署成功</p>
<ul>
<li><p>去除https<br>  CAS默认使用的是HTTPS协议，如果使用HTTPS协议需要SSL安全证书（需向特定的机构申请和购买） 。如果对安全要求不高或是在开发测试阶段，可使用HTTP协议。我们这里讲解通过修改配置，让CAS使用HTTP协议。</p>
<ul>
<li><p>修改cas的WEB-INF/deployerConfigContext.xml找到下面的配置<br><bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient"/><br>这里需要增加参数p:requireSecure=”false”，requireSecure属性意思为是否需要安全验证，即HTTPS，false为不采用</p>
</li>
<li><p>修改cas的/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml<br>找到下面配置<br><bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
 p:cookieSecure="true"
 p:cookieMaxAge="-1"
 p:cookieName="CASTGC"
 p:cookiePath="/cas" /></p>
</li>
<li><p>参数p:cookieSecure=”true”，同理为HTTPS验证相关，TRUE为采用HTTPS验证，FALSE为不采用https验证。<br>参数p:cookieMaxAge=”-1”，是COOKIE的最大生命周期，-1为无生命周期，即只在当前打开的窗口有效，关闭或重新打开其它窗口，仍会要求验证。可以根据需要修改为大于0的数字，比如3600等，意思是在3600秒内，打开任意窗口，都不需要验证。</p>
<p>   我们这里将cookieSecure改为false , cookieMaxAge 改为3600</p>
</li>
<li><p>修改cas的WEB-INF/spring-configuration/warnCookieGenerator.xml<br>   <bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
   p:cookieSecure="true"
   p:cookieMaxAge="-1"
   p:cookieName="CASPRIVACY"
   p:cookiePath="/cas" /><br>我们这里将cookieSecure改为false , cookieMaxAge 改为3600</p>
</li>
</ul>
</li>
</ul>
<ul>
<li>配置数据源<ul>
<li><p>cas有默认的密码但是实际中肯定是要从数据库中查的，所以我们需要配置下数据源</p>
</li>
<li><p>修改cas服务端中web-inf下deployerConfigContext.xml ，添加如下配置</p>
   <figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;bean id=<span class="string">&quot;dataSource&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;</span> </span><br><span class="line"> p:driverClass=<span class="string">&quot;com.mysql.jdbc.Driver&quot;</span></span><br><span class="line"> p:jdbcUrl=<span class="string">&quot;jdbc:mysql://127.0.0.1:3306/pinyougoudb?characterEncoding=utf8&quot;</span></span><br><span class="line"> p:user=<span class="string">&quot;root&quot;</span></span><br><span class="line"> p:password=<span class="string">&quot;123456&quot;</span> /&gt;</span><br><span class="line">&lt;bean id=<span class="string">&quot;passwordEncoder&quot;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.jasig.cas.authentication.handler.DefaultPasswordEncoder&quot;</span> </span><br><span class="line"> c:encodingAlgorithm=<span class="string">&quot;MD5&quot;</span></span><br><span class="line"> p:characterEncoding=<span class="string">&quot;UTF-8&quot;</span> /&gt;</span><br><span class="line">&lt;bean id=<span class="string">&quot;dbAuthHandler&quot;</span> </span><br><span class="line"> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler&quot;</span></span><br><span class="line"> p:dataSource-ref=<span class="string">&quot;dataSource&quot;</span></span><br><span class="line"> p:sql=<span class="string">&quot;select password from tb_user where username = ?&quot;</span></span><br><span class="line"> p:passwordEncoder-ref=<span class="string">&quot;passwordEncoder&quot;</span>/&gt;</span><br></pre></td></tr></table></figure></li>
<li><p>然后在配置文件开始部分找到如下配置</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"> &lt;bean id=<span class="string">&quot;authenticationManager&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.jasig.cas.authentication.PolicyBasedAuthenticationManager&quot;</span>&gt;</span><br><span class="line">        &lt;constructor-arg&gt;</span><br><span class="line">            &lt;map&gt;               </span><br><span class="line">                &lt;entry key-ref=<span class="string">&quot;proxyAuthenticationHandler&quot;</span> value-ref=<span class="string">&quot;proxyPrincipalResolver&quot;</span> /&gt;</span><br><span class="line">                &lt;entry key-ref=<span class="string">&quot;primaryAuthenticationHandler&quot;</span> value-ref=<span class="string">&quot;primaryPrincipalResolver&quot;</span> /&gt;</span><br><span class="line">            &lt;/map&gt;</span><br><span class="line">        &lt;/constructor-arg&gt;      </span><br><span class="line">        &lt;property name=<span class="string">&quot;authenticationPolicy&quot;</span>&gt;</span><br><span class="line">            &lt;bean <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.jasig.cas.authentication.AnyAuthenticationPolicy&quot;</span> /&gt;</span><br><span class="line">        &lt;/property&gt;</span><br><span class="line">&lt;/bean&gt;</span><br></pre></td></tr></table></figure>
<p>其中 <entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" />一句是使用固定的用户名和密码，我们在下面可以看到这两个bean ,如果我们使用数据库认证用户名和密码，需要将这句注释掉。<br>添加下面这一句配置</p>
<entry key-ref="dbAuthHandler" value-ref="primaryPrincipalResolver"/></li>
<li><p>将三个jar包加入到cas的lib目录下<br><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="https://imlgwpicture.oss-cn-qingdao.aliyuncs.com/blogImage/casjar.PNG"
                      alt="oss"
                ><br>第一个和第三个大家应该很熟悉了，中间的那个是cas对jdbc的支持包</p>
</li>
</ul>
</li>
</ul>
<hr>
<h3 id="2-普通的web项目集成CAS"><a href="#2-普通的web项目集成CAS" class="headerlink" title="2. 普通的web项目集成CAS"></a>2. 普通的web项目集成CAS</h3><p> 普通的web项目也就是没有使用Spring之类的框架而采用web.xml配置的普通项目</p>
<ul>
<li><p>2.1 为了方便我这里采用maven配置，先添加相应的依赖</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;!-- cas --&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.jasig.cas.client&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;cas-client-core&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;<span class="number">3.3</span><span class="number">.3</span>&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;javax.servlet&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;<span class="number">2.5</span>&lt;/version&gt;</span><br><span class="line">    &lt;scope&gt;provided&lt;/scope&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
<p>一个是cas客户端的核心包，一个是servlet的包，因为后面会写一些jsp<br>然后添加tomcat插件我设置的端口为9002</p>
</li>
<li><p>2.2 因为是普通的web项目所以配置的方式主要是通过web.xml来配置，直接上配置</p>
  <figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="line">&lt;web-app xmlns:xsi=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span><br><span class="line">         xmlns=<span class="string">&quot;http://java.sun.com/xml/ns/javaee&quot;</span></span><br><span class="line">         xsi:schemaLocation=<span class="string">&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;</span></span><br><span class="line">         version=<span class="string">&quot;2.5&quot;</span>&gt;</span><br><span class="line">    &lt;!-- 用于单点退出，该过滤器用于实现单点登出功能，可选配置 --&gt;</span><br><span class="line">    &lt;listener&gt;</span><br><span class="line">        &lt;listener-<span class="class"><span class="keyword">class</span>&gt;<span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">session</span>.<span class="title">SingleSignOutHttpSessionListener</span>&lt;/<span class="title">listener</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">listener</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;!-- 该过滤器用于实现单点登出功能，可选配置。 --&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">Single</span> <span class="title">Sign</span> <span class="title">Out</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">class</span>&gt;<span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">session</span>.<span class="title">SingleSignOutFilter</span>&lt;/<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">Single</span> <span class="title">Sign</span> <span class="title">Out</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">url</span>-<span class="title">pattern</span>&gt;/* &lt;/<span class="title">url</span>-<span class="title">pattern</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;!-- 该过滤器负责用户的认证工作，必须启用它 --&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CASFilter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">class</span>&gt;<span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">authentication</span>.<span class="title">AuthenticationFilter</span>&lt;/<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">name</span>&gt;<span class="title">casServerLoginUrl</span>&lt;/<span class="title">param</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">value</span>&gt;<span class="title">http</span>://<span class="title">localhost</span>:8888/<span class="title">cas</span>/<span class="title">login</span>&lt;/<span class="title">param</span>-<span class="title">value</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;!--这里的<span class="title">server</span>是服务端的<span class="title">IP</span> --&gt;</span></span><br><span class="line"><span class="class">        &lt;/<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">name</span>&gt;<span class="title">serverName</span>&lt;/<span class="title">param</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">value</span>&gt;<span class="title">http</span>://<span class="title">localhost</span>:9002&lt;/<span class="title">param</span>-<span class="title">value</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;/<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CASFilter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">url</span>-<span class="title">pattern</span>&gt;/*&lt;/<span class="title">url</span>-<span class="title">pattern</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;!-- 该过滤器负责对<span class="title">Ticket</span>的校验工作，必须启用它 --&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">Validation</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">class</span>&gt;<span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">validation</span>.<span class="title">Cas20ProxyReceivingTicketValidationFilter</span>&lt;/<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">name</span>&gt;<span class="title">casServerUrlPrefix</span>&lt;/<span class="title">param</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">value</span>&gt;<span class="title">http</span>://<span class="title">localhost</span>:8888/<span class="title">cas</span>&lt;/<span class="title">param</span>-<span class="title">value</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;/<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">name</span>&gt;<span class="title">serverName</span>&lt;/<span class="title">param</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">            &lt;<span class="title">param</span>-<span class="title">value</span>&gt;<span class="title">http</span>://<span class="title">localhost</span>:9002&lt;/<span class="title">param</span>-<span class="title">value</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;/<span class="title">init</span>-<span class="title">param</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">Validation</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">url</span>-<span class="title">pattern</span>&gt;/*&lt;/<span class="title">url</span>-<span class="title">pattern</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;!-- 该过滤器负责实现<span class="title">HttpServletRequest</span>请求的包裹， 比如允许开发者通过<span class="title">HttpServletRequest</span>的<span class="title">getRemoteUser</span>()方法获得<span class="title">SSO</span>登录用户的登录名，可选配置。 --&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">HttpServletRequest</span> <span class="title">Wrapper</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">            <span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">util</span>.*</span></span><br><span class="line"><span class="class">        &lt;/<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">HttpServletRequest</span> <span class="title">Wrapper</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">url</span>-<span class="title">pattern</span>&gt;/*&lt;/<span class="title">url</span>-<span class="title">pattern</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;!-- 该过滤器使得开发者可以通过<span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">util</span>.<span class="title">AssertionHolder</span>来获取用户的登录名。 比如<span class="title">AssertionHolder</span>.<span class="title">getAssertion</span>().<span class="title">getPrincipal</span>().<span class="title">getName</span>()。 --&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">Assertion</span> <span class="title">Thread</span> <span class="title">Local</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">class</span>&gt;<span class="title">org</span>.<span class="title">jasig</span>.<span class="title">cas</span>.<span class="title">client</span>.<span class="title">util</span>.<span class="title">AssertionThreadLocalFilter</span>&lt;/<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">CAS</span> <span class="title">Assertion</span> <span class="title">Thread</span> <span class="title">Local</span> <span class="title">Filter</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">url</span>-<span class="title">pattern</span>&gt;/*&lt;/<span class="title">url</span>-<span class="title">pattern</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">&lt;/<span class="title">web</span>-<span class="title">app</span>&gt;</span></span><br><span class="line"><span class="class"></span></span><br></pre></td></tr></table></figure>

<ul>
<li>用户认证过滤器(必选)<strong>AuthenticationFilter</strong>在上面的配置中需要两个参数一个是casServerLoginUrl顾名思义就是CASserver登陆的地址，比如我的是<a class="link"   target="_blank" rel="noopener" href="http://localhost:8888/cas/login" >http://localhost:8888/cas/login<i class="fas fa-external-link-alt"></i></a> ，第二个参数是<strong>serverName</strong> ,因为登陆成功后还是要返回你当前的应用所以需要将你当前的应用的地址传递给CASserver比如我的当前应用 <a class="link"   target="_blank" rel="noopener" href="http://localhost:9002/" >http://localhost:9002/<i class="fas fa-external-link-alt"></i></a></li>
<li>Ticket的校验过滤器(必选)<strong>Cas20ProxyReceivingTicketValidationFilter</strong> 与上面的过滤器类似也需要那两个参数，                              配置了这两个过滤器CAS就能正常运行了</li>
<li>单点登出过滤器 <strong>SingleSignOutFilter</strong>，顾名思义就是用于单点登出  </li>
<li>另外还有两个过滤器都是为了获取登陆名配置的过滤器，配置一个就行。    <h1 id=""><a href="#" class="headerlink" title=""></a></h1></li>
</ul>
</li>
<li><p>2.3 编写index.jsp(tomcat默认打开的页面)</p>
  <figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;%@ page language=<span class="string">&quot;java&quot;</span> contentType=<span class="string">&quot;text/html; charset=utf-8&quot;</span></span><br><span class="line">         pageEncoding=<span class="string">&quot;utf-8&quot;</span>%&gt;</span><br><span class="line">&lt;!DOCTYPE html PUBLIC <span class="string">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span> <span class="string">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span>&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">&lt;head&gt;</span><br><span class="line">    &lt;meta http-equiv=<span class="string">&quot;Content-Type&quot;</span> content=<span class="string">&quot;text/html; charset=utf-8&quot;</span>&gt;</span><br><span class="line">    &lt;title&gt;一品优购&lt;/title&gt;</span><br><span class="line">&lt;/head&gt;</span><br><span class="line">&lt;body&gt;</span><br><span class="line"> 采用web.xml配置的普通的web模块</span><br><span class="line">&lt;%=request.getRemoteUser()%&gt;</span><br><span class="line"> &lt;a href=<span class="string">&quot;http://localhost:8888/cas/logout?service=http://www.imlgw.top&quot;</span>&gt;退出登录&lt;/a&gt;&gt;</span><br><span class="line">&lt;/body&gt;</span><br><span class="line">&lt;/html&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>   如果想让cas退出后跳转到指定的页面而不是CAS默认的页面也需要修改配置<br>   修改cas系统的配置文件cas-servlet.xml<br>   <bean id="logoutAction" class="org.jasig.cas.web.flow.LogoutAction"
   p:servicesManager-ref="servicesManager"
   p:followServiceRedirects="${cas.logout.followServiceRedirects:true}"/><br>  将cas.logout.followServiceRedirects改为true后，可以在退出时跳转页面到目标页面<br> 然后就可以启动cas和你的应用来测试了。</p>
</li>
<li><p>2.4 服务端界面改造<br> 上面测试成功，但是真实的情况肯定不会用cas默认的那个页面做登陆需要改成你自己的登陆界面，然后你当前应用的登陆页面就没用了。</p>
  <figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;!DOCTYPE &gt;</span><br><span class="line">&lt;%@ page pageEncoding=<span class="string">&quot;UTF-8&quot;</span> %&gt;</span><br><span class="line">&lt;%@ page contentType=<span class="string">&quot;text/html; charset=UTF-8&quot;</span> %&gt;</span><br><span class="line">&lt;%@ taglib prefix=<span class="string">&quot;c&quot;</span> uri=<span class="string">&quot;http://java.sun.com/jsp/jstl/core&quot;</span> %&gt;</span><br><span class="line">&lt;%@ taglib prefix=<span class="string">&quot;spring&quot;</span> uri=<span class="string">&quot;http://www.springframework.org/tags&quot;</span> %&gt;</span><br><span class="line">&lt;%@ taglib prefix=<span class="string">&quot;form&quot;</span> uri=<span class="string">&quot;http://www.springframework.org/tags/form&quot;</span> %&gt;</span><br><span class="line">&lt;%@ taglib prefix=<span class="string">&quot;fn&quot;</span> uri=<span class="string">&quot;http://java.sun.com/jsp/jstl/functions&quot;</span> %&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">&quot;UTF-8&quot;</span> /&gt;</span><br><span class="line">		&lt;title&gt;Login&lt;/title&gt;</span><br><span class="line">		&lt;link rel=<span class="string">&quot;stylesheet&quot;</span> type=<span class="string">&quot;text/css&quot;</span> href=<span class="string">&#x27;bs/css/bootstrap.min.css&#x27;</span> /&gt;</span><br><span class="line">		&lt;script type=<span class="string">&quot;text/javascript&quot;</span> src=<span class="string">&quot;js/jquery.min.js&quot;</span>&gt;&lt;/script&gt;</span><br><span class="line">		&lt;script type=<span class="string">&quot;text/javascript&quot;</span> src=<span class="string">&quot;bs/js/bootstrap.min.js&quot;</span>&gt;&lt;/script&gt;</span><br><span class="line">		&lt;style&gt;</span><br><span class="line">			img &#123;</span><br><span class="line">				height: 200px;</span><br><span class="line">				border-radius: 200px;</span><br><span class="line">			&#125;</span><br><span class="line">			.panel-title&#123;</span><br><span class="line">				text-align: center;</span><br><span class="line">			&#125;</span><br><span class="line">			.login &#123;</span><br><span class="line">				width: 500px;</span><br><span class="line">				height: 400px;</span><br><span class="line">				position: absolute;</span><br><span class="line">				top: <span class="number">20</span>%;</span><br><span class="line">				left: <span class="number">50</span>%;</span><br><span class="line">				margin-left: -250px;</span><br><span class="line">			&#125;</span><br><span class="line">			.sub&#123;</span><br><span class="line">				text-align: center;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">		&lt;/style&gt;</span><br><span class="line">	&lt;/head&gt;</span><br><span class="line"></span><br><span class="line">	&lt;body&gt;</span><br><span class="line">		&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;panel panel-primary login&quot;</span>&gt;</span><br><span class="line">			&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;panel-heading&quot;</span>&gt;</span><br><span class="line">				&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;panel-title&quot;</span>&gt;</span><br><span class="line">					&lt;img src=<span class="string">&quot;images/login.jpg&quot;</span> /&gt;</span><br><span class="line">				&lt;/div&gt;</span><br><span class="line">			&lt;/div&gt;</span><br><span class="line">			&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;panel-body&quot;</span>&gt;</span><br><span class="line">				&lt;!--自定义的登陆界面修改 <span class="number">1</span> --&gt;</span><br><span class="line">				&lt;form:form method=<span class="string">&quot;post&quot;</span> id=<span class="string">&quot;fm1&quot;</span> commandName=<span class="string">&quot;$&#123;commandName&#125;&quot;</span> htmlEscape=<span class="string">&quot;true&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;sui-form&quot;</span>&gt;</span><br><span class="line">				</span><br><span class="line">					&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">						&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;input-group&quot;</span>&gt;</span><br><span class="line">							&lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;input-group-addon&quot;</span> id=<span class="string">&quot;basic-addon1&quot;</span>&gt;&lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;glyphicon glyphicon-user&quot;</span>&gt;&lt;/span&gt;&lt;/span&gt;</span><br><span class="line">							&lt;!--自定义的登陆界面修改 <span class="number">2</span> --&gt;</span><br><span class="line">							&lt;form:input  <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> aria-describedby=<span class="string">&quot;basic-addon1&quot;</span> placeholder=<span class="string">&quot;Username&quot;</span>  id=<span class="string">&quot;username&quot;</span> size=<span class="string">&quot;25&quot;</span> tabindex=<span class="string">&quot;1&quot;</span> accesskey=<span class="string">&quot;$&#123;userNameAccessKey&#125;&quot;</span> path=<span class="string">&quot;username&quot;</span> autocomplete=<span class="string">&quot;off&quot;</span> htmlEscape=<span class="string">&quot;true&quot;</span> /&gt;</span><br><span class="line">						&lt;/div&gt;</span><br><span class="line">					&lt;/div&gt;</span><br><span class="line">					&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">						&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;input-group&quot;</span>&gt;</span><br><span class="line">							&lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;input-group-addon&quot;</span> id=<span class="string">&quot;basic-addon1&quot;</span>&gt;&lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;glyphicon glyphicon-lock&quot;</span>&gt;&lt;/span&gt;&lt;/span&gt;</span><br><span class="line">							&lt;!--自定义的登陆界面修改 <span class="number">3</span> --&gt;</span><br><span class="line">							&lt;form:password <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> placeholder=<span class="string">&quot;password&quot;</span> aria-describedby=<span class="string">&quot;basic-addon1&quot;</span> id=<span class="string">&quot;password&quot;</span> size=<span class="string">&quot;25&quot;</span> tabindex=<span class="string">&quot;2&quot;</span> path=<span class="string">&quot;password&quot;</span>  accesskey=<span class="string">&quot;$&#123;passwordAccessKey&#125;&quot;</span> htmlEscape=<span class="string">&quot;true&quot;</span> autocomplete=<span class="string">&quot;off&quot;</span> /&gt;</span><br><span class="line">						&lt;/div&gt;</span><br><span class="line">					&lt;/div&gt;</span><br><span class="line">					&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group sub&quot;</span>&gt;</span><br><span class="line">						&lt;!--自定义的登陆界面修改 <span class="number">4</span> 登陆框 --&gt;</span><br><span class="line">						&lt;input type=<span class="string">&quot;hidden&quot;</span> name=<span class="string">&quot;lt&quot;</span> value=<span class="string">&quot;$&#123;loginTicket&#125;&quot;</span> /&gt;</span><br><span class="line">     	 				&lt;input type=<span class="string">&quot;hidden&quot;</span> name=<span class="string">&quot;execution&quot;</span> value=<span class="string">&quot;$&#123;flowExecutionKey&#125;&quot;</span> /&gt;</span><br><span class="line">      					&lt;input type=<span class="string">&quot;hidden&quot;</span> name=<span class="string">&quot;_eventId&quot;</span> value=<span class="string">&quot;submit&quot;</span> /&gt;</span><br><span class="line">      					&lt;input <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-primary btn-lg&quot;</span> name=<span class="string">&quot;submit&quot;</span> accesskey=<span class="string">&quot;l&quot;</span> value=<span class="string">&quot;登陆&quot;</span> type=<span class="string">&quot;submit&quot;</span> /&gt;</span><br><span class="line">      					&lt;!--自定义的登陆界面修改 <span class="number">4</span> 错误提示框 --&gt;</span><br><span class="line">      					&lt;form:errors path=<span class="string">&quot;*&quot;</span> id=<span class="string">&quot;msg&quot;</span> cssClass=<span class="string">&quot;errors&quot;</span> element=<span class="string">&quot;div&quot;</span> htmlEscape=<span class="string">&quot;false&quot;</span> /&gt;</span><br><span class="line">					&lt;/div&gt;</span><br><span class="line">				&lt;/form:form&gt;</span><br><span class="line">			&lt;/div&gt;</span><br><span class="line">		&lt;/div&gt;</span><br><span class="line"></span><br><span class="line">	&lt;/body&gt;</span><br><span class="line"></span><br><span class="line">&lt;/html&gt;</span><br></pre></td></tr></table></figure>
<p>  可以直接将登陆的页面拷过来然后加上指令再根据cas的登陆页面稍加修改就可以了</p>
</li>
</ul>
<hr>
<h3 id="3-Spring项目集成CAS和Spring-security"><a href="#3-Spring项目集成CAS和Spring-security" class="headerlink" title="3. Spring项目集成CAS和Spring-security"></a>3. Spring项目集成CAS和Spring-security</h3><ul>
<li>pom依赖  <figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;properties&gt;</span><br><span class="line">        &lt;spring.version&gt;<span class="number">4.2</span><span class="number">.0</span>.RELEASE&lt;/spring.version&gt;</span><br><span class="line">    &lt;/properties&gt;</span><br><span class="line">    &lt;dependencies&gt;</span><br><span class="line">        &lt;!-- Spring --&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-context&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-jms&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;!--spring-security--&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;<span class="number">3.1</span><span class="number">.0</span>&lt;/version&gt;</span><br><span class="line">            &lt;scope&gt;provided&lt;/scope&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;!--集成包--&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;spring-security-cas&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;$&#123;spring.version&#125;&lt;/version&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">        &lt;!--cas--&gt;</span><br><span class="line">        &lt;dependency&gt;</span><br><span class="line">            &lt;groupId&gt;org.jasig.cas.client&lt;/groupId&gt;</span><br><span class="line">            &lt;artifactId&gt;cas-client-core&lt;/artifactId&gt;</span><br><span class="line">            &lt;version&gt;<span class="number">3.3</span><span class="number">.3</span>&lt;/version&gt;</span><br><span class="line">            &lt;exclusions&gt;</span><br><span class="line">                &lt;exclusion&gt;</span><br><span class="line">                    &lt;groupId&gt;org.slf4j&lt;/groupId&gt;</span><br><span class="line">                    &lt;artifactId&gt;log4j-over-slf4j&lt;/artifactId&gt;</span><br><span class="line">                &lt;/exclusion&gt;</span><br><span class="line">            &lt;/exclusions&gt;</span><br><span class="line">        &lt;/dependency&gt;</span><br><span class="line">    &lt;/dependencies&gt;</span><br></pre></td></tr></table></figure>
  添加tomcat插件指定端口为9001</li>
<li>web.xml配置<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="line">&lt;web-app xmlns:xsi=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span><br><span class="line">         xmlns=<span class="string">&quot;http://java.sun.com/xml/ns/javaee&quot;</span></span><br><span class="line">         xsi:schemaLocation=<span class="string">&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;</span></span><br><span class="line">         version=<span class="string">&quot;2.5&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">    &lt;context-param&gt;</span><br><span class="line">        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;</span><br><span class="line">        &lt;param-value&gt;classpath:spring/spring-*.xml&lt;/param-value&gt;</span><br><span class="line">    &lt;/context-param&gt;</span><br><span class="line">    &lt;listener&gt;</span><br><span class="line">        &lt;listener-<span class="class"><span class="keyword">class</span>&gt;</span></span><br><span class="line"><span class="class">            <span class="title">org</span>.<span class="title">springframework</span>.<span class="title">web</span>.<span class="title">context</span>.<span class="title">ContextLoaderListener</span></span></span><br><span class="line"><span class="class">        &lt;/<span class="title">listener</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">listener</span>&gt;</span></span><br><span class="line"><span class="class"></span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">springSecurityFilterChain</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">class</span>&gt;<span class="title">org</span>.<span class="title">springframework</span>.<span class="title">web</span>.<span class="title">filter</span>.<span class="title">DelegatingFilterProxy</span>&lt;/<span class="title">filter</span>-<span class="title">class</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">filter</span>-<span class="title">name</span>&gt;<span class="title">springSecurityFilterChain</span>&lt;/<span class="title">filter</span>-<span class="title">name</span>&gt;</span></span><br><span class="line"><span class="class">        &lt;<span class="title">url</span>-<span class="title">pattern</span>&gt;/*&lt;/<span class="title">url</span>-<span class="title">pattern</span>&gt;</span></span><br><span class="line"><span class="class">    &lt;/<span class="title">filter</span>-<span class="title">mapping</span>&gt;</span></span><br><span class="line"><span class="class"></span></span><br><span class="line"><span class="class">&lt;/<span class="title">web</span>-<span class="title">app</span>&gt;</span></span><br></pre></td></tr></table></figure>
主要配置Spring容器和Spring-security的过滤器</li>
</ul>
<ul>
<li>spring-security.xml配置<br>其实就是把之前配置在web.xml里面的过滤器采用Spring的方式配置出来</li>
</ul>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="line">&lt;beans:beans xmlns=<span class="string">&quot;http://www.springframework.org/schema/security&quot;</span></span><br><span class="line">             xmlns:beans=<span class="string">&quot;http://www.springframework.org/schema/beans&quot;</span> xmlns:xsi=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span><br><span class="line">             xsi:schemaLocation=<span class="string">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</span></span><br><span class="line"><span class="string">						http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">    &lt;http pattern=<span class="string">&quot;/out.html&quot;</span> security=<span class="string">&quot;none&quot;</span>&gt;&lt;/http&gt;</span><br><span class="line">    &lt;!--   entry-point-ref  入口点引用 因为登陆交给cas或者其他的登陆系统,就不会在本系统做登陆需要指定登陆点--&gt;</span><br><span class="line">    &lt;http use-expressions=<span class="string">&quot;false&quot;</span> entry-point-ref=<span class="string">&quot;casProcessingFilterEntryPoint&quot;</span>&gt;</span><br><span class="line">        &lt;intercept-url pattern=<span class="string">&quot;/**&quot;</span> access=<span class="string">&quot;ROLE_USER&quot;</span>/&gt;</span><br><span class="line">        &lt;csrf disabled=<span class="string">&quot;true&quot;</span>/&gt;</span><br><span class="line">        &lt;!-- custom-filter为过滤器， position 表示将过滤器放在指定的位置上，before表示放在指定位置之前  ，after表示放在指定的位置之后  --&gt;</span><br><span class="line">        &lt;custom-filter ref=<span class="string">&quot;casAuthenticationFilter&quot;</span>  position=<span class="string">&quot;CAS_FILTER&quot;</span> /&gt;</span><br><span class="line">        &lt;custom-filter ref=<span class="string">&quot;requestSingleLogoutFilter&quot;</span> before=<span class="string">&quot;LOGOUT_FILTER&quot;</span>/&gt;</span><br><span class="line">        &lt;custom-filter ref=<span class="string">&quot;singleLogoutFilter&quot;</span> before=<span class="string">&quot;CAS_FILTER&quot;</span>/&gt;</span><br><span class="line">    &lt;/http&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!-- CAS入口点 开始 --&gt;</span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;casProcessingFilterEntryPoint&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.cas.web.CasAuthenticationEntryPoint&quot;</span>&gt;</span><br><span class="line">        &lt;!-- 单点登录服务器登录URL --&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;loginUrl&quot;</span> value=<span class="string">&quot;http://localhost:8888/cas/login&quot;</span>/&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;serviceProperties&quot;</span> ref=<span class="string">&quot;serviceProperties&quot;</span>/&gt;</span><br><span class="line">    &lt;/beans:bean&gt;</span><br><span class="line"></span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;serviceProperties&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.cas.ServiceProperties&quot;</span>&gt;</span><br><span class="line">        &lt;!--service 配置自身工程的根地址+/login/cas   --&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;service&quot;</span> value=<span class="string">&quot;http://localhost:9001/login/cas&quot;</span>/&gt;</span><br><span class="line">    &lt;/beans:bean&gt;</span><br><span class="line">    &lt;!-- CAS入口点 结束 --&gt;</span><br><span class="line">    &lt;!-- 认证过滤器 开始 --&gt;</span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;casAuthenticationFilter&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.cas.web.CasAuthenticationFilter&quot;</span>&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;authenticationManager&quot;</span> ref=<span class="string">&quot;authenticationManager&quot;</span>/&gt;</span><br><span class="line">    &lt;/beans:bean&gt;</span><br><span class="line">    &lt;!-- 认证管理器 --&gt;</span><br><span class="line">    &lt;authentication-manager alias=<span class="string">&quot;authenticationManager&quot;</span>&gt;</span><br><span class="line">        &lt;authentication-provider  ref=<span class="string">&quot;casAuthenticationProvider&quot;</span>&gt;</span><br><span class="line">        &lt;/authentication-provider&gt;</span><br><span class="line">    &lt;/authentication-manager&gt;</span><br><span class="line">    &lt;!-- 认证提供者 --&gt;</span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;casAuthenticationProvider&quot;</span>     <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.cas.authentication.CasAuthenticationProvider&quot;</span>&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;authenticationUserDetailsService&quot;</span>&gt;</span><br><span class="line">            &lt;beans:bean <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper&quot;</span>&gt;</span><br><span class="line">                &lt;beans:constructor-arg ref=<span class="string">&quot;userDetailsService&quot;</span> /&gt;</span><br><span class="line">            &lt;/beans:bean&gt;</span><br><span class="line">        &lt;/beans:property&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;serviceProperties&quot;</span> ref=<span class="string">&quot;serviceProperties&quot;</span>/&gt;</span><br><span class="line">        &lt;!-- ticketValidator 为票据验证器 --&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;ticketValidator&quot;</span>&gt;</span><br><span class="line">            &lt;beans:bean <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.jasig.cas.client.validation.Cas20ServiceTicketValidator&quot;</span>&gt;</span><br><span class="line">                &lt;beans:constructor-arg index=<span class="string">&quot;0&quot;</span> value=<span class="string">&quot;http://localhost:8888/cas&quot;</span>/&gt;</span><br><span class="line">            &lt;/beans:bean&gt;</span><br><span class="line">        &lt;/beans:property&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;key&quot;</span> value=<span class="string">&quot;an_id_for_this_auth_provider_only&quot;</span>/&gt;</span><br><span class="line">    &lt;/beans:bean&gt;</span><br><span class="line">    &lt;!-- 认证类 --&gt;</span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;userDetailsService&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;top.imlgw.demo.UserDetailServiceImpl&quot;</span>/&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!-- 认证过滤器 结束 --&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &lt;!-- 单点登出  开始  --&gt;</span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;singleLogoutFilter&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.jasig.cas.client.session.SingleSignOutFilter&quot;</span>/&gt;</span><br><span class="line">    &lt;!--关联两个地址，相当于封装了前面的地址--&gt;</span><br><span class="line">    &lt;beans:bean id=<span class="string">&quot;requestSingleLogoutFilter&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.web.authentication.logout.LogoutFilter&quot;</span>&gt;</span><br><span class="line">        &lt;beans:constructor-arg value=<span class="string">&quot;http://localhost:8888/cas/logout?service=http://localhost:9001/out.html&quot;</span>/&gt;</span><br><span class="line">        &lt;beans:constructor-arg&gt;</span><br><span class="line">            &lt;beans:bean <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler&quot;</span>/&gt;</span><br><span class="line">        &lt;/beans:constructor-arg&gt;</span><br><span class="line">        &lt;beans:property name=<span class="string">&quot;filterProcessesUrl&quot;</span> value=<span class="string">&quot;/logout/cas&quot;</span>/&gt;</span><br><span class="line">    &lt;/beans:bean&gt;</span><br><span class="line">    &lt;!-- 单点登出  结束 --&gt;</span><br><span class="line"></span><br><span class="line">&lt;/beans:beans&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>userDetailsService编写<br>这是一个认证类是属于Spring-security的，如果不使用CAS那么这个类就是用来验证密码是否正确是否放行的。但是整合了CAS后就不用在里面做认证了，只是为了返回后面的角色集合。</p>
  <figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> top.imlgw.demo;</span><br><span class="line"><span class="keyword">import</span> org.springframework.security.core.GrantedAuthority;</span><br><span class="line"><span class="keyword">import</span> org.springframework.security.core.authority.SimpleGrantedAuthority;</span><br><span class="line"><span class="keyword">import</span> org.springframework.security.core.userdetails.User;</span><br><span class="line"><span class="keyword">import</span> org.springframework.security.core.userdetails.UserDetails;</span><br><span class="line"><span class="keyword">import</span> org.springframework.security.core.userdetails.UserDetailsService;</span><br><span class="line"><span class="keyword">import</span> org.springframework.security.core.userdetails.UsernameNotFoundException;</span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UserDetailServiceImpl</span> <span class="keyword">implements</span> <span class="title">UserDetailsService</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> UserDetails <span class="title">loadUserByUsername</span><span class="params">(String username)</span> <span class="keyword">throws</span> UsernameNotFoundException </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;经过认证类&quot;</span>);</span><br><span class="line">        List&lt;GrantedAuthority&gt; authorities=<span class="keyword">new</span> ArrayList();</span><br><span class="line">        <span class="comment">//最开始把这里的role写错了，然后cas登陆成功后也一直被403 forbid，因为SpringSecurity认证没通过，一直没放行</span></span><br><span class="line">        authorities.add(<span class="keyword">new</span> SimpleGrantedAuthority(<span class="string">&quot;ROLE_USER&quot;</span>));</span><br><span class="line">        <span class="comment">//不通过本项目做登陆 所以密码无所谓，在执行这个方法的时候就已经登陆成功了</span></span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> User(username,<span class="string">&quot;&quot;</span>,authorities);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
<h3 id="4-测试"><a href="#4-测试" class="headerlink" title="4. 测试"></a>4. 测试</h3><p>启动搭建好的两个服务器，和casServer，然后测试在一个应用登陆后另一个能否进入index页面 …..</p>
<hr>
<p>SpringBoot集成CAS和Spring-security的后面再补充，因为SpringBoot还不太熟悉。</p>

        </div>

        
            <div class="post-copyright-info">
                <div class="article-copyright-info-container">
    <ul>
        <li>本文标题：CAS单点登陆系统Demo</li>
        <li>本文作者：Resolmi</li>
        <li>创建时间：2018-11-17 00:00:00</li>
        <li>
            本文链接：https://imlgw.top/2018/11/17/65571397/
        </li>
        <li>
            版权声明：本博客所有文章除特别声明外，均采用 <a class="license" target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">BY-NC-SA</a> 许可协议。转载请注明出处！
        </li>
    </ul>
</div>

            </div>
        

        
            <div class="article-nav">
                
                    <div class="article-prev">
                        <a class="prev"
                           rel="prev"
                           href="/2018/11/26/2dc72c90/"
                        >
                            <span class="left arrow-icon flex-center">
                              <i class="fas fa-chevron-left"></i>
                            </span>
                            <span class="title flex-center">
                                <span class="post-nav-title-item">Spring-Security遇到的小问题</span>
                                <span class="post-nav-item">上一篇</span>
                            </span>
                        </a>
                    </div>
                
                
                    <div class="article-next">
                        <a class="next"
                           rel="next"
                           href="/2018/10/31/96e09a6a/"
                        >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">一道LeetCode引发的惨案</span>
                                <span class="post-nav-item">下一篇</span>
                            </span>
                            <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        

        
            <div class="comment-container">
                <div class="comments-container">
    <div id="comment-anchor"></div>
    <div class="comment-area-title">
        <i class="fas fa-comments">&nbsp;评论</i>
    </div>
    

        
            <section class="disqus-comments">
<div id="disqus_thread">
  <noscript>Please enable JavaScript to view the <a target="_blank" rel="noopener" href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>

<script>
var disqus_shortname = 'imlgw';

var disqus_url = 'https://imlgw.top/2018/11/17/65571397/';

(function(){
  var dsq = document.createElement('script');
  dsq.type = 'text/javascript';
  dsq.async = true;
  dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>

<script id="dsq-count-scr" src="//imlgw.disqus.com/count.js" async></script>
        
    
</div>

            </div>
        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2018</span>&nbsp;-&nbsp;
            
            2021&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">Resolmi</a>
        </div>
        
            <script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    <span id="busuanzi_container_site_uv">
                        访问人数&nbsp;<span id="busuanzi_value_site_uv"></span>&ensp;
                    </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        总访问量&nbsp;<span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        
            <div class="icp-info info-item"><a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn">鄂ICP备18011208号</a></div>
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item page-aside-toggle">
                <i class="fas fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
            <li class="go-comment">
                <i class="fas fa-comment"></i>
            </li>
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="arrow-up fas fa-arrow-up"></i>
                <span class="percent"></span>
            </li>
        
    </ul>
</div>

    </div>

    
        <aside class="page-aside">
            <div class="post-toc-wrap">
    <div class="post-toc">
        <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%95%E7%82%B9%E7%99%BB%E9%99%86%E7%B3%BB%E7%BB%9F-%E2%80%93CAS"><span class="nav-number">1.</span> <span class="nav-text">单点登陆系统 –CAS</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-%E9%85%8D%E7%BD%AECAS%E6%9C%8D%E5%8A%A1%E7%AB%AF"><span class="nav-number">1.1.</span> <span class="nav-text">1. 配置CAS服务端</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-%E6%99%AE%E9%80%9A%E7%9A%84web%E9%A1%B9%E7%9B%AE%E9%9B%86%E6%88%90CAS"><span class="nav-number">1.2.</span> <span class="nav-text">2. 普通的web项目集成CAS</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link"><span class="nav-number"></span> <span class="nav-text"></span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-Spring%E9%A1%B9%E7%9B%AE%E9%9B%86%E6%88%90CAS%E5%92%8CSpring-security"><span class="nav-number">0.1.</span> <span class="nav-text">3. Spring项目集成CAS和Spring-security</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-%E6%B5%8B%E8%AF%95"><span class="nav-number">0.2.</span> <span class="nav-text">4. 测试</span></a></li></ol></li></ol>
    </div>
</div>
        </aside>
    

    <div class="image-viewer-container">
    <img src="">
</div>


    
        <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
          <span class="search-input-field-pre">
            <i class="fas fa-keyboard"></i>
          </span>
            <div class="search-input-container">
                <input autocomplete="off"
                       autocorrect="off"
                       autocapitalize="off"
                       placeholder="搜索..."
                       spellcheck="false"
                       type="search"
                       class="search-input"
                >
            </div>
            <span class="popup-btn-close">
                <i class="fas fa-times"></i>
            </span>
        </div>
        <div id="search-result">
            <div id="no-result">
                <i class="fas fa-spinner fa-pulse fa-5x fa-fw"></i>
            </div>
        </div>
    </div>
</div>

    

</main>



<script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/utils.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/main.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/header-shrink.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/back2top.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/dark-light-toggle.js"></script>


    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/local-search.js"></script>



    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/code-copy.js"></script>



    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/lazyload.js"></script>


<div class="post-scripts pjax">
    
        <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/left-side-toggle.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/libs/anime.min.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/toc.js"></script>
    
</div>


    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.3/source/js/libs/pjax.min.js"></script>
<script>
    window.addEventListener('DOMContentLoaded', () => {
        window.pjax = new Pjax({
            selectors: [
                'head title',
                '.page-container',
                '.pjax'
            ],
            history: true,
            debug: false,
            cacheBust: false,
            timeout: 0,
            analytics: false,
            currentUrlFullReload: false,
            scrollRestoration: false,
            // scrollTo: true,
        });

        document.addEventListener('pjax:send', () => {
            KEEP.utils.pjaxProgressBarStart();
        });

        document.addEventListener('pjax:complete', () => {
            KEEP.utils.pjaxProgressBarEnd();
            window.pjax.executeScripts(document.querySelectorAll('script[data-pjax], .pjax script'));
            KEEP.refresh();
        });
    });
</script>



<script src="https://cdn.jsdelivr.net/npm/live2d-widget@3.x/lib/L2Dwidget.min.js"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"https://cdn.jsdelivr.net/npm/live2d-widget-model-hijiki@1.0.5/assets/hijiki.model.json"},"display":{"superSample":2,"width":160,"height":320,"position":"right","hOffset":0,"vOffset":-70},"mobile":{"show":false,"scale":0.2},"log":false});</script></body>
</html>
